import Vue from 'vue'
import VueRouter from 'vue-router'

// 注册路由插件
Vue.use(VueRouter)
// 解决报错

const originalPush = VueRouter.prototype.push
const originalReplace = VueRouter.prototype.replace
// push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
// replace
VueRouter.prototype.replace = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
  return originalReplace.call(this, location).catch(err => err)
}
const routes = [{
		path: '/',
		name: 'Home',
		component: () => import('../views/home.vue')

	},
	{
		path: '/tb_list',
		name: 'List',
		component: () => import('../views/tb_list.vue')
	},
	{
		path: '/order',
		name: 'Order',
		component: () => import('../views/order.vue')
	},
	{
		path: '/order_add',
		name: 'Order_add',
		component: () => import('../views/order_add.vue')
	},
	{
		path: '/user_add',
		name: 'User_add',
		component: () => import('../views/user_add.vue')
	},
	,
	{
		path: '/tb_list_add',
		name: 'Tb_list_add',
		component: () => import('../views/tb_list_add.vue')
	},
	{
		path: '/post/:id',
		name: 'post',
		component: () => import('../components/Post/Post.vue')
	},
	{
		path: '/user_edit/:id',
		name: 'user_edit',
		component: () => import('../components/Post/user_edit.vue')
	},
	{
		path: '/order_edit/:id',
		name: 'order_edit',
		component: () => import('../components/Post/order_edit.vue')
	},
	{
		path: '/login',
		name: 'Login',
		component: () => import('../views/login.vue')
	},
	{
		path: '/register',
		name: 'Register',
		component: () => import('../views/register.vue')
	},
	{
		path: '/user',
		name: 'User',
		component: () => import('../views/user.vue')
	}
]

const router = new VueRouter({
	routes
})

//暴露路由
export default router
